package com.anyou.mall.goo.goodsSku.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.goodsSku.domain.GooGoodsSku;
import com.anyou.mall.goo.goodsSku.service.IGooGoodsSkuService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 商品sku规格组合Controller
 *
 * @author xq
 * @date 2022-03-28
 */
@Api(tags = "商品sku规格组合")
@RestController
@RequestMapping("/goo/goodsSku")
public class GooGoodsSkuController extends BaseController
{
    @Autowired
    private IGooGoodsSkuService gooGoodsSkuService;

    /**
     * 查询商品sku规格组合列表
     */
    @ApiOperation("查询商品sku规格组合列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:list')")
    @GetMapping("/list")
    public TableDataInfo<List<GooGoodsSku>> list(GooGoodsSku gooGoodsSku)
    {
        startPage();
        List<GooGoodsSku> list = gooGoodsSkuService.selectGooGoodsSkuList(gooGoodsSku);
        return getDataTable(list);
    }

    /**
     * 导出商品sku规格组合列表
     */
    @ApiOperation("导出商品sku规格组合列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:export')")
    @Log(title = "商品sku规格组合", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GooGoodsSku gooGoodsSku)
    {
        List<GooGoodsSku> list = gooGoodsSkuService.selectGooGoodsSkuList(gooGoodsSku);
        ExcelUtil<GooGoodsSku> util = new ExcelUtil<GooGoodsSku>(GooGoodsSku.class);
        util.exportExcel(response, list, "商品sku规格组合数据");
    }

    /**
     * 获取商品sku规格组合详细信息
     */
    @ApiOperation("获取商品sku规格组合详细信息")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:query')")
    @GetMapping(value = "/{goodsSkuId}")
    public ApiResult<GooGoodsSku> getInfo(@PathVariable("goodsSkuId") Long goodsSkuId)
    {
        return ApiResult.success(gooGoodsSkuService.selectGooGoodsSkuByGoodsSkuId(goodsSkuId));
    }

    /**
     * 新增商品sku规格组合
     */
    @ApiOperation("新增商品sku规格组合")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:add')")
    @Log(title = "商品sku规格组合", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody GooGoodsSku gooGoodsSku)
    {
        return ApiResult.success(gooGoodsSkuService.insertGooGoodsSku(gooGoodsSku));
    }

    /**
     * 修改商品sku规格组合
     */
    @ApiOperation("修改商品sku规格组合")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:edit')")
    @Log(title = "商品sku规格组合", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody GooGoodsSku gooGoodsSku)
    {
        return ApiResult.success(gooGoodsSkuService.updateGooGoodsSku(gooGoodsSku));
    }

    /**
     * 删除商品sku规格组合
     */
    @ApiOperation("删除商品sku规格组合")
    @PreAuthorize("@ss.hasPermi('goo:goodsSku:remove')")
    @Log(title = "商品sku规格组合", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsSkuIds}")
    public ApiResult remove(@PathVariable Long[] goodsSkuIds)
    {
        return ApiResult.success(gooGoodsSkuService.deleteGooGoodsSkuByGoodsSkuIds(goodsSkuIds));
    }
}
